<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - code analysis - src/caffe/layer_factory.cpp</title>
  <link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../index.html">top level</a> - <a href="index.html">src/caffe</a> - layer_factory.cpp<span style="font-size: 80%;"> (source / <a href="layer_factory.cpp.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">code analysis</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">26</td>
            <td class="headerCovTableEntry">51</td>
            <td class="headerCovTableEntryLo">51.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2020-09-11 22:50:33</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">6</td>
            <td class="headerCovTableEntry">18</td>
            <td class="headerCovTableEntryLo">33.3 %</td>
          </tr>
          <tr>
            <td class="headerItem">Legend:</td>
            <td class="headerValueLeg">            Lines:
            <span class="coverLegendCov">hit</span>
            <span class="coverLegendNoCov">not hit</span>
</td>
            <td></td>
          </tr>
          <tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : // Make sure we include Python.h before any system header</a>
<span class="lineNum">       2 </span>            : // to avoid _POSIX_C_SOURCE redefinition
<span class="lineNum">       3 </span>            : #ifdef WITH_PYTHON_LAYER
<span class="lineNum">       4 </span>            : #include &lt;boost/python.hpp&gt;
<span class="lineNum">       5 </span>            : #endif
<span class="lineNum">       6 </span>            : #include &lt;string&gt;
<span class="lineNum">       7 </span>            : 
<span class="lineNum">       8 </span>            : #include &quot;caffe/layer.hpp&quot;
<span class="lineNum">       9 </span>            : #include &quot;caffe/layer_factory.hpp&quot;
<span class="lineNum">      10 </span>            : #include &quot;caffe/layers/clip_layer.hpp&quot;
<span class="lineNum">      11 </span>            : #include &quot;caffe/layers/conv_layer.hpp&quot;
<span class="lineNum">      12 </span>            : #include &quot;caffe/layers/deconv_layer.hpp&quot;
<span class="lineNum">      13 </span>            : #include &quot;caffe/layers/lrn_layer.hpp&quot;
<span class="lineNum">      14 </span>            : #include &quot;caffe/layers/pooling_layer.hpp&quot;
<span class="lineNum">      15 </span>            : #include &quot;caffe/layers/relu_layer.hpp&quot;
<span class="lineNum">      16 </span>            : #include &quot;caffe/layers/sigmoid_layer.hpp&quot;
<span class="lineNum">      17 </span>            : #include &quot;caffe/layers/softmax_layer.hpp&quot;
<span class="lineNum">      18 </span>            : #include &quot;caffe/layers/tanh_layer.hpp&quot;
<span class="lineNum">      19 </span>            : #include &quot;caffe/proto/caffe.pb.h&quot;
<span class="lineNum">      20 </span>            : 
<span class="lineNum">      21 </span>            : #ifdef USE_CUDNN
<span class="lineNum">      22 </span>            : #include &quot;caffe/layers/cudnn_conv_layer.hpp&quot;
<span class="lineNum">      23 </span>            : #include &quot;caffe/layers/cudnn_deconv_layer.hpp&quot;
<span class="lineNum">      24 </span>            : #include &quot;caffe/layers/cudnn_lcn_layer.hpp&quot;
<span class="lineNum">      25 </span>            : #include &quot;caffe/layers/cudnn_lrn_layer.hpp&quot;
<span class="lineNum">      26 </span>            : #include &quot;caffe/layers/cudnn_pooling_layer.hpp&quot;
<span class="lineNum">      27 </span>            : #include &quot;caffe/layers/cudnn_relu_layer.hpp&quot;
<span class="lineNum">      28 </span>            : #include &quot;caffe/layers/cudnn_sigmoid_layer.hpp&quot;
<span class="lineNum">      29 </span>            : #include &quot;caffe/layers/cudnn_softmax_layer.hpp&quot;
<span class="lineNum">      30 </span>            : #include &quot;caffe/layers/cudnn_tanh_layer.hpp&quot;
<span class="lineNum">      31 </span>            : #endif
<span class="lineNum">      32 </span>            : 
<span class="lineNum">      33 </span>            : #ifdef WITH_PYTHON_LAYER
<span class="lineNum">      34 </span>            : #include &quot;caffe/layers/python_layer.hpp&quot;
<span class="lineNum">      35 </span>            : #endif
<span class="lineNum">      36 </span>            : 
<span class="lineNum">      37 </span>            : namespace caffe {
<span class="lineNum">      38 </span>            : 
<a name="39"><span class="lineNum">      39 </span>            : // Get convolution layer according to engine.</a>
<span class="lineNum">      40 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      41 </span><span class="lineCov">          4 : shared_ptr&lt;Layer&lt;Dtype&gt; &gt; GetConvolutionLayer(</span>
<span class="lineNum">      42 </span>            :     const LayerParameter&amp; param) {
<span class="lineNum">      43 </span><span class="lineCov">          8 :   ConvolutionParameter conv_param = param.convolution_param();</span>
<span class="lineNum">      44 </span>            :   ConvolutionParameter_Engine engine = conv_param.engine();
<span class="lineNum">      45 </span>            : #ifdef USE_CUDNN
<span class="lineNum">      46 </span>            :   bool use_dilation = false;
<span class="lineNum">      47 </span>            :   for (int i = 0; i &lt; conv_param.dilation_size(); ++i) {
<span class="lineNum">      48 </span>            :     if (conv_param.dilation(i) &gt; 1) {
<span class="lineNum">      49 </span>            :       use_dilation = true;
<span class="lineNum">      50 </span>            :     }
<span class="lineNum">      51 </span>            :   }
<span class="lineNum">      52 </span>            : #endif
<span class="lineNum">      53 </span><span class="lineCov">          4 :   if (engine == ConvolutionParameter_Engine_DEFAULT) {</span>
<span class="lineNum">      54 </span>            :     engine = ConvolutionParameter_Engine_CAFFE;
<span class="lineNum">      55 </span>            : #ifdef USE_CUDNN
<span class="lineNum">      56 </span>            :     if (!use_dilation) {
<span class="lineNum">      57 </span>            :       engine = ConvolutionParameter_Engine_CUDNN;
<span class="lineNum">      58 </span>            :     }
<span class="lineNum">      59 </span>            : #endif
<span class="lineNum">      60 </span>            :   }
<span class="lineNum">      61 </span><span class="lineCov">          4 :   if (engine == ConvolutionParameter_Engine_CAFFE) {</span>
<span class="lineNum">      62 </span><span class="lineCov">         12 :     return shared_ptr&lt;Layer&lt;Dtype&gt; &gt;(new ConvolutionLayer&lt;Dtype&gt;(param));</span>
<span class="lineNum">      63 </span>            : #ifdef USE_CUDNN
<span class="lineNum">      64 </span>            :   } else if (engine == ConvolutionParameter_Engine_CUDNN) {
<span class="lineNum">      65 </span>            :     if (use_dilation) {
<span class="lineNum">      66 </span>            :       LOG(FATAL) &lt;&lt; &quot;CuDNN doesn't support the dilated convolution at Layer &quot;
<span class="lineNum">      67 </span>            :                  &lt;&lt; param.name();
<span class="lineNum">      68 </span>            :     }
<span class="lineNum">      69 </span>            :     return shared_ptr&lt;Layer&lt;Dtype&gt; &gt;(new CuDNNConvolutionLayer&lt;Dtype&gt;(param));
<span class="lineNum">      70 </span>            : #endif
<span class="lineNum">      71 </span>            :   } else {
<span class="lineNum">      72 </span><span class="lineNoCov">          0 :     LOG(FATAL) &lt;&lt; &quot;Layer &quot; &lt;&lt; param.name() &lt;&lt; &quot; has unknown engine.&quot;;</span>
<span class="lineNum">      73 </span>            :     throw;  // Avoids missing return warning
<span class="lineNum">      74 </span>            :   }
<span class="lineNum">      75 </span>            : }
<span class="lineNum">      76 </span>            : 
<span class="lineNum">      77 </span><span class="lineCov">          3 : REGISTER_LAYER_CREATOR(Convolution, GetConvolutionLayer);</span>
<span class="lineNum">      78 </span>            : 
<a name="79"><span class="lineNum">      79 </span>            : // Get deconvolution layer according to engine.</a>
<span class="lineNum">      80 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      81 </span><span class="lineNoCov">          0 : shared_ptr&lt;Layer&lt;Dtype&gt; &gt; GetDeconvolutionLayer(const LayerParameter&amp; param) {</span>
<span class="lineNum">      82 </span><span class="lineNoCov">          0 :   ConvolutionParameter conv_param = param.convolution_param();</span>
<span class="lineNum">      83 </span>            :   ConvolutionParameter_Engine engine = conv_param.engine();
<span class="lineNum">      84 </span>            : #ifdef USE_CUDNN
<span class="lineNum">      85 </span>            :   bool use_dilation = false;
<span class="lineNum">      86 </span>            :   for (int i = 0; i &lt; conv_param.dilation_size(); ++i) {
<span class="lineNum">      87 </span>            :     if (conv_param.dilation(i) &gt; 1) {
<span class="lineNum">      88 </span>            :       use_dilation = true;
<span class="lineNum">      89 </span>            :     }
<span class="lineNum">      90 </span>            :   }
<span class="lineNum">      91 </span>            : #endif
<span class="lineNum">      92 </span><span class="lineNoCov">          0 :   if (engine == ConvolutionParameter_Engine_DEFAULT) {</span>
<span class="lineNum">      93 </span>            :     engine = ConvolutionParameter_Engine_CAFFE;
<span class="lineNum">      94 </span>            : #ifdef USE_CUDNN
<span class="lineNum">      95 </span>            :     if (!use_dilation) {
<span class="lineNum">      96 </span>            :       engine = ConvolutionParameter_Engine_CUDNN;
<span class="lineNum">      97 </span>            :     }
<span class="lineNum">      98 </span>            : #endif
<span class="lineNum">      99 </span>            :   }
<span class="lineNum">     100 </span><span class="lineNoCov">          0 :   if (engine == ConvolutionParameter_Engine_CAFFE) {</span>
<span class="lineNum">     101 </span><span class="lineNoCov">          0 :     return shared_ptr&lt;Layer&lt;Dtype&gt; &gt;(new DeconvolutionLayer&lt;Dtype&gt;(param));</span>
<span class="lineNum">     102 </span>            : #ifdef USE_CUDNN
<span class="lineNum">     103 </span>            :   } else if (engine == ConvolutionParameter_Engine_CUDNN) {
<span class="lineNum">     104 </span>            :     if (use_dilation) {
<span class="lineNum">     105 </span>            :       LOG(FATAL) &lt;&lt; &quot;CuDNN doesn't support the dilated deconvolution at Layer &quot;
<span class="lineNum">     106 </span>            :                  &lt;&lt; param.name();
<span class="lineNum">     107 </span>            :     }
<span class="lineNum">     108 </span>            :     return shared_ptr&lt;Layer&lt;Dtype&gt; &gt;(new CuDNNDeconvolutionLayer&lt;Dtype&gt;(param));
<span class="lineNum">     109 </span>            : #endif
<span class="lineNum">     110 </span>            :   } else {
<span class="lineNum">     111 </span><span class="lineNoCov">          0 :     LOG(FATAL) &lt;&lt; &quot;Layer &quot; &lt;&lt; param.name() &lt;&lt; &quot; has unknown engine.&quot;;</span>
<span class="lineNum">     112 </span>            :     throw;  // Avoids missing return warning
<span class="lineNum">     113 </span>            :   }
<span class="lineNum">     114 </span>            : }
<span class="lineNum">     115 </span>            : 
<span class="lineNum">     116 </span><span class="lineCov">          3 : REGISTER_LAYER_CREATOR(Deconvolution, GetDeconvolutionLayer);</span>
<span class="lineNum">     117 </span>            : 
<a name="118"><span class="lineNum">     118 </span>            : // Get pooling layer according to engine.</a>
<span class="lineNum">     119 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     120 </span><span class="lineCov">          4 : shared_ptr&lt;Layer&lt;Dtype&gt; &gt; GetPoolingLayer(const LayerParameter&amp; param) {</span>
<span class="lineNum">     121 </span>            :   PoolingParameter_Engine engine = param.pooling_param().engine();
<span class="lineNum">     122 </span><span class="lineCov">          4 :   if (engine == PoolingParameter_Engine_DEFAULT) {</span>
<span class="lineNum">     123 </span>            :     engine = PoolingParameter_Engine_CAFFE;
<span class="lineNum">     124 </span>            : #ifdef USE_CUDNN
<span class="lineNum">     125 </span>            :     engine = PoolingParameter_Engine_CUDNN;
<span class="lineNum">     126 </span>            : #endif
<span class="lineNum">     127 </span>            :   }
<span class="lineNum">     128 </span><span class="lineCov">          4 :   if (engine == PoolingParameter_Engine_CAFFE) {</span>
<span class="lineNum">     129 </span><span class="lineCov">          4 :     return shared_ptr&lt;Layer&lt;Dtype&gt; &gt;(new PoolingLayer&lt;Dtype&gt;(param));</span>
<span class="lineNum">     130 </span>            : #ifdef USE_CUDNN
<span class="lineNum">     131 </span>            :   } else if (engine == PoolingParameter_Engine_CUDNN) {
<span class="lineNum">     132 </span>            :     if (param.top_size() &gt; 1) {
<span class="lineNum">     133 </span>            :       LOG(INFO) &lt;&lt; &quot;cuDNN does not support multiple tops. &quot;
<span class="lineNum">     134 </span>            :                 &lt;&lt; &quot;Using Caffe's own pooling layer.&quot;;
<span class="lineNum">     135 </span>            :       return shared_ptr&lt;Layer&lt;Dtype&gt; &gt;(new PoolingLayer&lt;Dtype&gt;(param));
<span class="lineNum">     136 </span>            :     }
<span class="lineNum">     137 </span>            :     // CuDNN assumes layers are not being modified in place, thus
<span class="lineNum">     138 </span>            :     // breaking our index tracking for updates in some cases in Caffe.
<span class="lineNum">     139 </span>            :     // Until there is a workaround in Caffe (index management) or
<span class="lineNum">     140 </span>            :     // cuDNN, use Caffe layer to max pooling, or don't use in place
<span class="lineNum">     141 </span>            :     // layers after max pooling layers
<span class="lineNum">     142 </span>            :     if (param.pooling_param().pool() == PoolingParameter_PoolMethod_MAX) {
<span class="lineNum">     143 </span>            :         return shared_ptr&lt;Layer&lt;Dtype&gt; &gt;(new PoolingLayer&lt;Dtype&gt;(param));
<span class="lineNum">     144 </span>            :     } else {
<span class="lineNum">     145 </span>            :         return shared_ptr&lt;Layer&lt;Dtype&gt; &gt;(new CuDNNPoolingLayer&lt;Dtype&gt;(param));
<span class="lineNum">     146 </span>            :     }
<span class="lineNum">     147 </span>            : #endif
<span class="lineNum">     148 </span>            :   } else {
<span class="lineNum">     149 </span><span class="lineNoCov">          0 :     LOG(FATAL) &lt;&lt; &quot;Layer &quot; &lt;&lt; param.name() &lt;&lt; &quot; has unknown engine.&quot;;</span>
<span class="lineNum">     150 </span>            :     throw;  // Avoids missing return warning
<span class="lineNum">     151 </span>            :   }
<span class="lineNum">     152 </span>            : }
<span class="lineNum">     153 </span>            : 
<span class="lineNum">     154 </span><span class="lineCov">          3 : REGISTER_LAYER_CREATOR(Pooling, GetPoolingLayer);</span>
<span class="lineNum">     155 </span>            : 
<a name="156"><span class="lineNum">     156 </span>            : // Get LRN layer according to engine</a>
<span class="lineNum">     157 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     158 </span><span class="lineNoCov">          0 : shared_ptr&lt;Layer&lt;Dtype&gt; &gt; GetLRNLayer(const LayerParameter&amp; param) {</span>
<span class="lineNum">     159 </span>            :   LRNParameter_Engine engine = param.lrn_param().engine();
<span class="lineNum">     160 </span>            : 
<span class="lineNum">     161 </span><span class="lineNoCov">          0 :   if (engine == LRNParameter_Engine_DEFAULT) {</span>
<span class="lineNum">     162 </span>            : #ifdef USE_CUDNN
<span class="lineNum">     163 </span>            :     engine = LRNParameter_Engine_CUDNN;
<span class="lineNum">     164 </span>            : #else
<span class="lineNum">     165 </span>            :     engine = LRNParameter_Engine_CAFFE;
<span class="lineNum">     166 </span>            : #endif
<span class="lineNum">     167 </span>            :   }
<span class="lineNum">     168 </span>            : 
<span class="lineNum">     169 </span><span class="lineNoCov">          0 :   if (engine == LRNParameter_Engine_CAFFE) {</span>
<span class="lineNum">     170 </span><span class="lineNoCov">          0 :     return shared_ptr&lt;Layer&lt;Dtype&gt; &gt;(new LRNLayer&lt;Dtype&gt;(param));</span>
<span class="lineNum">     171 </span>            : #ifdef USE_CUDNN
<span class="lineNum">     172 </span>            :   } else if (engine == LRNParameter_Engine_CUDNN) {
<span class="lineNum">     173 </span>            :     LRNParameter lrn_param = param.lrn_param();
<span class="lineNum">     174 </span>            : 
<span class="lineNum">     175 </span>            :     if (lrn_param.norm_region() ==LRNParameter_NormRegion_WITHIN_CHANNEL) {
<span class="lineNum">     176 </span>            :       return shared_ptr&lt;Layer&lt;Dtype&gt; &gt;(new CuDNNLCNLayer&lt;Dtype&gt;(param));
<span class="lineNum">     177 </span>            :     } else {
<span class="lineNum">     178 </span>            :       // local size is too big to be handled through cuDNN
<span class="lineNum">     179 </span>            :       if (param.lrn_param().local_size() &gt; CUDNN_LRN_MAX_N) {
<span class="lineNum">     180 </span>            :         return shared_ptr&lt;Layer&lt;Dtype&gt; &gt;(new LRNLayer&lt;Dtype&gt;(param));
<span class="lineNum">     181 </span>            :       } else {
<span class="lineNum">     182 </span>            :         return shared_ptr&lt;Layer&lt;Dtype&gt; &gt;(new CuDNNLRNLayer&lt;Dtype&gt;(param));
<span class="lineNum">     183 </span>            :       }
<span class="lineNum">     184 </span>            :     }
<span class="lineNum">     185 </span>            : #endif
<span class="lineNum">     186 </span>            :   } else {
<span class="lineNum">     187 </span><span class="lineNoCov">          0 :     LOG(FATAL) &lt;&lt; &quot;Layer &quot; &lt;&lt; param.name() &lt;&lt; &quot; has unknown engine.&quot;;</span>
<span class="lineNum">     188 </span>            :     throw;  // Avoids missing return warning
<span class="lineNum">     189 </span>            :   }
<span class="lineNum">     190 </span>            : }
<span class="lineNum">     191 </span>            : 
<span class="lineNum">     192 </span><span class="lineCov">          3 : REGISTER_LAYER_CREATOR(LRN, GetLRNLayer);</span>
<span class="lineNum">     193 </span>            : 
<a name="194"><span class="lineNum">     194 </span>            : // Get relu layer according to engine.</a>
<span class="lineNum">     195 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     196 </span><span class="lineCov">          2 : shared_ptr&lt;Layer&lt;Dtype&gt; &gt; GetReLULayer(const LayerParameter&amp; param) {</span>
<span class="lineNum">     197 </span>            :   ReLUParameter_Engine engine = param.relu_param().engine();
<span class="lineNum">     198 </span><span class="lineCov">          2 :   if (engine == ReLUParameter_Engine_DEFAULT) {</span>
<span class="lineNum">     199 </span>            :     engine = ReLUParameter_Engine_CAFFE;
<span class="lineNum">     200 </span>            : #ifdef USE_CUDNN
<span class="lineNum">     201 </span>            :     engine = ReLUParameter_Engine_CUDNN;
<span class="lineNum">     202 </span>            : #endif
<span class="lineNum">     203 </span>            :   }
<span class="lineNum">     204 </span><span class="lineCov">          2 :   if (engine == ReLUParameter_Engine_CAFFE) {</span>
<span class="lineNum">     205 </span><span class="lineCov">          4 :     return shared_ptr&lt;Layer&lt;Dtype&gt; &gt;(new ReLULayer&lt;Dtype&gt;(param));</span>
<span class="lineNum">     206 </span>            : #ifdef USE_CUDNN
<span class="lineNum">     207 </span>            :   } else if (engine == ReLUParameter_Engine_CUDNN) {
<span class="lineNum">     208 </span>            :     return shared_ptr&lt;Layer&lt;Dtype&gt; &gt;(new CuDNNReLULayer&lt;Dtype&gt;(param));
<span class="lineNum">     209 </span>            : #endif
<span class="lineNum">     210 </span>            :   } else {
<span class="lineNum">     211 </span><span class="lineNoCov">          0 :     LOG(FATAL) &lt;&lt; &quot;Layer &quot; &lt;&lt; param.name() &lt;&lt; &quot; has unknown engine.&quot;;</span>
<span class="lineNum">     212 </span>            :     throw;  // Avoids missing return warning
<span class="lineNum">     213 </span>            :   }
<span class="lineNum">     214 </span>            : }
<span class="lineNum">     215 </span>            : 
<span class="lineNum">     216 </span><span class="lineCov">          3 : REGISTER_LAYER_CREATOR(ReLU, GetReLULayer);</span>
<span class="lineNum">     217 </span>            : 
<a name="218"><span class="lineNum">     218 </span>            : // Get sigmoid layer according to engine.</a>
<span class="lineNum">     219 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     220 </span><span class="lineNoCov">          0 : shared_ptr&lt;Layer&lt;Dtype&gt; &gt; GetSigmoidLayer(const LayerParameter&amp; param) {</span>
<span class="lineNum">     221 </span>            :   SigmoidParameter_Engine engine = param.sigmoid_param().engine();
<span class="lineNum">     222 </span><span class="lineNoCov">          0 :   if (engine == SigmoidParameter_Engine_DEFAULT) {</span>
<span class="lineNum">     223 </span>            :     engine = SigmoidParameter_Engine_CAFFE;
<span class="lineNum">     224 </span>            : #ifdef USE_CUDNN
<span class="lineNum">     225 </span>            :     engine = SigmoidParameter_Engine_CUDNN;
<span class="lineNum">     226 </span>            : #endif
<span class="lineNum">     227 </span>            :   }
<span class="lineNum">     228 </span><span class="lineNoCov">          0 :   if (engine == SigmoidParameter_Engine_CAFFE) {</span>
<span class="lineNum">     229 </span><span class="lineNoCov">          0 :     return shared_ptr&lt;Layer&lt;Dtype&gt; &gt;(new SigmoidLayer&lt;Dtype&gt;(param));</span>
<span class="lineNum">     230 </span>            : #ifdef USE_CUDNN
<span class="lineNum">     231 </span>            :   } else if (engine == SigmoidParameter_Engine_CUDNN) {
<span class="lineNum">     232 </span>            :     return shared_ptr&lt;Layer&lt;Dtype&gt; &gt;(new CuDNNSigmoidLayer&lt;Dtype&gt;(param));
<span class="lineNum">     233 </span>            : #endif
<span class="lineNum">     234 </span>            :   } else {
<span class="lineNum">     235 </span><span class="lineNoCov">          0 :     LOG(FATAL) &lt;&lt; &quot;Layer &quot; &lt;&lt; param.name() &lt;&lt; &quot; has unknown engine.&quot;;</span>
<span class="lineNum">     236 </span>            :     throw;  // Avoids missing return warning
<span class="lineNum">     237 </span>            :   }
<span class="lineNum">     238 </span>            : }
<span class="lineNum">     239 </span>            : 
<span class="lineNum">     240 </span><span class="lineCov">          3 : REGISTER_LAYER_CREATOR(Sigmoid, GetSigmoidLayer);</span>
<span class="lineNum">     241 </span>            : 
<a name="242"><span class="lineNum">     242 </span>            : // Get softmax layer according to engine.</a>
<span class="lineNum">     243 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     244 </span><span class="lineCov">          2 : shared_ptr&lt;Layer&lt;Dtype&gt; &gt; GetSoftmaxLayer(const LayerParameter&amp; param) {</span>
<span class="lineNum">     245 </span>            :   SoftmaxParameter_Engine engine = param.softmax_param().engine();
<span class="lineNum">     246 </span><span class="lineCov">          2 :   if (engine == SoftmaxParameter_Engine_DEFAULT) {</span>
<span class="lineNum">     247 </span>            :     engine = SoftmaxParameter_Engine_CAFFE;
<span class="lineNum">     248 </span>            : #ifdef USE_CUDNN
<span class="lineNum">     249 </span>            :     engine = SoftmaxParameter_Engine_CUDNN;
<span class="lineNum">     250 </span>            : #endif
<span class="lineNum">     251 </span>            :   }
<span class="lineNum">     252 </span><span class="lineCov">          2 :   if (engine == SoftmaxParameter_Engine_CAFFE) {</span>
<span class="lineNum">     253 </span><span class="lineCov">          2 :     return shared_ptr&lt;Layer&lt;Dtype&gt; &gt;(new SoftmaxLayer&lt;Dtype&gt;(param));</span>
<span class="lineNum">     254 </span>            : #ifdef USE_CUDNN
<span class="lineNum">     255 </span>            :   } else if (engine == SoftmaxParameter_Engine_CUDNN) {
<span class="lineNum">     256 </span>            :     return shared_ptr&lt;Layer&lt;Dtype&gt; &gt;(new CuDNNSoftmaxLayer&lt;Dtype&gt;(param));
<span class="lineNum">     257 </span>            : #endif
<span class="lineNum">     258 </span>            :   } else {
<span class="lineNum">     259 </span><span class="lineNoCov">          0 :     LOG(FATAL) &lt;&lt; &quot;Layer &quot; &lt;&lt; param.name() &lt;&lt; &quot; has unknown engine.&quot;;</span>
<span class="lineNum">     260 </span>            :     throw;  // Avoids missing return warning
<span class="lineNum">     261 </span>            :   }
<span class="lineNum">     262 </span>            : }
<span class="lineNum">     263 </span>            : 
<span class="lineNum">     264 </span><span class="lineCov">          3 : REGISTER_LAYER_CREATOR(Softmax, GetSoftmaxLayer);</span>
<span class="lineNum">     265 </span>            : 
<a name="266"><span class="lineNum">     266 </span>            : // Get tanh layer according to engine.</a>
<span class="lineNum">     267 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     268 </span><span class="lineNoCov">          0 : shared_ptr&lt;Layer&lt;Dtype&gt; &gt; GetTanHLayer(const LayerParameter&amp; param) {</span>
<span class="lineNum">     269 </span>            :   TanHParameter_Engine engine = param.tanh_param().engine();
<span class="lineNum">     270 </span><span class="lineNoCov">          0 :   if (engine == TanHParameter_Engine_DEFAULT) {</span>
<span class="lineNum">     271 </span>            :     engine = TanHParameter_Engine_CAFFE;
<span class="lineNum">     272 </span>            : #ifdef USE_CUDNN
<span class="lineNum">     273 </span>            :     engine = TanHParameter_Engine_CUDNN;
<span class="lineNum">     274 </span>            : #endif
<span class="lineNum">     275 </span>            :   }
<span class="lineNum">     276 </span><span class="lineNoCov">          0 :   if (engine == TanHParameter_Engine_CAFFE) {</span>
<span class="lineNum">     277 </span><span class="lineNoCov">          0 :     return shared_ptr&lt;Layer&lt;Dtype&gt; &gt;(new TanHLayer&lt;Dtype&gt;(param));</span>
<span class="lineNum">     278 </span>            : #ifdef USE_CUDNN
<span class="lineNum">     279 </span>            :   } else if (engine == TanHParameter_Engine_CUDNN) {
<span class="lineNum">     280 </span>            :     return shared_ptr&lt;Layer&lt;Dtype&gt; &gt;(new CuDNNTanHLayer&lt;Dtype&gt;(param));
<span class="lineNum">     281 </span>            : #endif
<span class="lineNum">     282 </span>            :   } else {
<span class="lineNum">     283 </span><span class="lineNoCov">          0 :     LOG(FATAL) &lt;&lt; &quot;Layer &quot; &lt;&lt; param.name() &lt;&lt; &quot; has unknown engine.&quot;;</span>
<span class="lineNum">     284 </span>            :     throw;  // Avoids missing return warning
<span class="lineNum">     285 </span>            :   }
<span class="lineNum">     286 </span>            : }
<span class="lineNum">     287 </span>            : 
<span class="lineNum">     288 </span><span class="lineCov">          3 : REGISTER_LAYER_CREATOR(TanH, GetTanHLayer);</span>
<span class="lineNum">     289 </span>            : 
<span class="lineNum">     290 </span>            : #ifdef WITH_PYTHON_LAYER
<span class="lineNum">     291 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     292 </span>            : shared_ptr&lt;Layer&lt;Dtype&gt; &gt; GetPythonLayer(const LayerParameter&amp; param) {
<span class="lineNum">     293 </span>            :   Py_Initialize();
<span class="lineNum">     294 </span>            :   try {
<span class="lineNum">     295 </span>            :     bp::object module = bp::import(param.python_param().module().c_str());
<span class="lineNum">     296 </span>            :     bp::object layer = module.attr(param.python_param().layer().c_str())(param);
<span class="lineNum">     297 </span>            :     return bp::extract&lt;shared_ptr&lt;PythonLayer&lt;Dtype&gt; &gt; &gt;(layer)();
<span class="lineNum">     298 </span>            :   } catch (bp::error_already_set) {
<span class="lineNum">     299 </span>            :     PyErr_Print();
<span class="lineNum">     300 </span>            :     throw;
<span class="lineNum">     301 </span>            :   }
<span class="lineNum">     302 </span>            : }
<span class="lineNum">     303 </span>            : 
<span class="lineNum">     304 </span>            : REGISTER_LAYER_CREATOR(Python, GetPythonLayer);
<span class="lineNum">     305 </span>            : #endif
<span class="lineNum">     306 </span>            : 
<a name="307"><span class="lineNum">     307 </span>            : // Layers that use their constructor as their default creator should be</a>
<span class="lineNum">     308 </span>            : // registered in their corresponding cpp files. Do not register them here.
<span class="lineNum">     309 </span><span class="lineCov">          3 : }  // namespace caffe</span>
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.12</a></td></tr>
  </table>
  <br>

</body>
</html>
